using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using UnityEngine.SceneManagement;
using WorkFlow.Games._1_GameEntrance.Scripts;

public static class EntranceParams
    {
        public static StartConfig GameStartConfig { get; set; }
        public static GameTagEnum GameTag { get; set; }
        public static string GameDataTail { get; set; }
        public static string SceneName { get; set; }
        public static string ToolsName { get; set; }
        public static string TreasureChestId { get; set; }
        public static string InSceneData { get; set; }
        /// <summary>
        /// 工具运行要求的最低APP版本
        /// </summary>
        public static string AppMinVersion { get; set; }
        public static string RequireSceneAbKey { get; set; }
        public static bool EntranceSceneStarted { get; private set; }
#if !UNITY_EDITOR
           = true;
#endif
        /// <summary>
        /// 工具所在资源版本
        /// </summary>
        public static string ToolVersion { get; set; }
        public static Dictionary<string,string> OriginDictionary { get; set; }
        public static string FindToolVersion()
        {
            if (GameStartConfig != null)
            {
                if (GameStartConfig.CurrentVersionTool.Contains(SceneName))
                    return ToolBaseConfig.Version;
                foreach (var pair in GameStartConfig.OtherVersionTool)
                {
                    if (pair.Value.Contains(SceneName))
                    {
                        return pair.Key;
                    }
                }
            }

            return string.Empty;
        }
        
#if UNITY_EDITOR
        public static string Token { get; set; }
        [UnityEditor.InitializeOnEnterPlayMode]
        private static void SetReally()
        {
            EntranceSceneStarted = SceneManager.GetActiveScene().name ==  "Entrance";
        }
#endif
    }
    [System.Serializable]
    public class StartConfig
    {
        //[JsonIgnore][Obsolete("请直接使用 ToolBaseConfig.ToolsVersion")] public string Version => ToolBaseConfig.ToolsVersion;
        /// <summary>
        /// 默认从StreamingAssets加载的工具
        /// </summary>
        public HashSet<string> StreamingGame { get; set; }
        /// <summary>
        /// 补丁集合
        /// </summary>
        public Dictionary<string,string> Hotfix { get; set; }
        public HashSet<string> CurrentVersionTool { get; set; }
        /// <summary>
        /// 其他版本发布的工具
        /// </summary>
        public Dictionary<string,HashSet<string>> OtherVersionTool { get; set; }
    }

    public enum GameTagEnum
    {
        /// <summary>
        /// 冥想
        /// </summary>
        MEDITATE,

        /// <summary>
        /// 工具
        /// </summary>
        TOOL,

        /// <summary>
        /// 绘本
        /// </summary>
        PICTURE_BOOK
    }